<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎注册--订餐系统</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0,maximum-scale=1.0, user-scalable=no" />
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.css">
    <link rel="stylesheet" href="static/css/login.css" type="text/css" />
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
</head>

<body>
    <section class="body-sign">
        <div class="center-sign">
            <a href="#" class="logo">ORDER</a>
            <div class="sign-in">
                <div class="sign-title">
                    <h2 class="title"><i style="font-size:13px;margin-right: 5px;" class="fa">&#xf007</i>注 册</h2>
                </div>
                <div class="sign-body">
                    <form action="${pageContext.request.contextPath}/admin/adminRegister" method="post" accept-charset="utf-8">
                        <div style="color: red;text-align: center">${msg}</div>
                        <div class="form-group">
                            <label>
                                <font style="vertical-align: inherit;">管理员账号</font>
                            </label>
                            <div class="input-group input-group-icon">
                                <input name="username" type="text" value="" class="form-control input-lg" id="us">
                                <span class="input-group-addon">
                                    <i style="font-size:19px;margin-right: 5px;" class="fa">&#xf007</i>
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="clearfix">
                                <label class="pull-left">
                                    <font style="vertical-align: inherit;">密码</font>
                                </label>
                            </div>
                            <div class="input-group input-group-icon">
                                <input name="password" type="password" value="" class="form-control input-lg" id="ps">
                                <span class="input-group-addon">
                                    <i style="font-size:19px" class="fa">&#xf023</i>
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="clearfix">
                                <label class="pull-left">
                                    <font style="vertical-align: inherit;">姓名</font>
                                </label>
                            </div>
                            <div class="input-group input-group-icon">
                                <input name="name" type="text" value="" class="form-control input-lg" id="code">
                                <span class="input-group-addon">
                                    <i style="font-size:19px" class="fa">&#xf2ba</i>
                                </span>
                            </div>
                        </div>
                        <div class="row">
                            <div style="text-align: center;">
                                <button class="btn btn-primary" lay-submit="" lay-filter="login" id="btn-req">注 册</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </section>
    <script type="text/javascript">
        // 用户注册
        $(document).ready(function() {
            $("#btn-reg").click(function() {

                var us = $('#us').val();
                var ps = $('#ps').val();
                var code = $("#code").val();

                $.ajax({
                    url: 'http://39.105.232.109:3000/user/login',
                    type: 'POST',
                    dataType: "JSON",
                    data: {
                        us: us,
                        ps: ps,
                        code: code
                    },

                    success: function(data) {
                        if (data.err == 0) {
                            window.location.href = 'index2.jsp'
                            var login_id = data.login_id
                            localStorage.setItem("login_id", login_id)
                        } else {
                            alert(data.msg)
                        }
                    }
                })
            });
        });
    </script>
</body>